feat(http-client-python): add encode/boolean Spector mock API tests + fix boolean-as-string encoding#11087
Draft
Copilot wants to merge 5 commits into
Draft
feat(http-client-python): add encode/boolean Spector mock API tests + fix boolean-as-string encoding#11087Copilot wants to merge 5 commits into
Copilot wants to merge 5 commits into
Conversation
…oolean string encode support - Add `encode/boolean` to regenerate-common.ts spec list - Bump @typespec/http-specs to 0.1.0-alpha.39-dev.4 (includes encode/boolean spec) - Fix TCGC to propagate encode=string for boolean types - Fix Python generator BooleanType to set encode="str" when @encode(string) is used - Add _deserialize_bool_as_str to model_base.py.jinja2 template - Add sync and async mock API tests for azure and unbranded flavors - Add changelog entry Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
…n assertions Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test case for pull request 10875
feat(http-client-python): add encode/boolean Spector mock API tests + fix boolean-as-string encoding
Jun 24, 2026
Contributor
|
Need new compiler version to support this feature. |
msyyc
reviewed
Jun 25, 2026
… feature Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Python SDK mock API test coverage for the
encode/booleanSpector scenarios from #10875 (@encode(string)on boolean types). This required fixing multiple layers of the Python codegen stack that were not yet aware of boolean string encoding.Generator fixes
primitive_types.py—BooleanTypeAdded
__init__to detectyaml_data["encode"] == "string"and setself.encode = "str", mirroring the existingIntegerTypebehavior.model_base.py.jinja2Added
_deserialize_bool_as_strto correctly handle case-insensitive string→bool deserialization. Python's built-inbool("false")returnsTrue(any non-empty string is truthy), so a dedicated deserializer is required:Also added the corresponding dispatch in
get_deserializerforannotation is bool and rf._format == "str".Test coverage
4 new test files (sync + async × azure + unbranded) covering all Spector scenarios:
trueLower— sends/receives"true", deserializes toTruefalseLower— sends/receives"false", deserializes toFalsetrueUpper— sends/receives"TRUE", deserializes toTruefalseMixed— sends/receives"FaLsE", deserializes toFalseDependencies
@typespec/http-specsto0.1.0-alpha.39-dev.4(first version containing theencode/booleanspec)encode/booleantoregenerate-common.ts